package edu.ort.domain

class UserController {

	def scaffold = true
	
	def login = {}

	def doLogin = { 
		def user = User.findWhere(email:params['email'],password:params['password'])
		session.user = user
		if (user)
			redirect(controller:'gasto',action:'index')
		else
			redirect(controller:'user',action:'login')
	}
        
        def logout = {
            if (session.user) {
                def email = session.user.email
                session.user = null
                flash.message = "El usuario "  + email + " se ha desconectado correctamente"
            }
            redirect(action:login)
        }
}
